﻿using System.Collections.Generic;
using Socium.Domain.Tests;
using Socium.Presentation;

namespace Socium.TestEditor {
	class VariantTreeItem : TreeItemBase<Variant> {
		public VariantTreeItem(Variant model) : base(model) {}

		public override IEnumerable<CommandViewModel> Commands {
			get { 
				return new[] {
			        new CommandViewModel("Delete", new Command<IFormViewService>(OnDelete)), 
			        new CommandViewModel("Properties...", new Command<IFormViewService>(OnDetail)), 
			    }; 
			}
		}

		void OnDetail(IFormViewService form_view_service) {
			Details(form_view_service, model => new VariantViewModel(model));
		}

		void OnDelete(IFormViewService form_view_service) {
			var parent = (ClosedQuestionTreeItem) Parent;
			parent.Childeren.Remove(this);
		}

		protected override string GetDisplayName(Variant model) {
			return model.Text;
		}
	}
}
